﻿using System;
using NUnit.Framework;
using Moq;

namespace SimpleStore
{
	[TestFixture]
	public class ProductTest
	{
		[Test]
		public void ShouldCalculatePriceWithTax()
		{
			const double basePrice = 45.99;
			const double taxRate = 2.70;
			const double expectedTaxAmount = 1.24;
			Product aProduct = new Product{Name="Some useful item", Price=basePrice};
			var mockTaxCalculator = new Mock<TaxCalculator>(taxRate);
			mockTaxCalculator.Setup(c => c.CalculateTaxAmount(basePrice)).Returns(expectedTaxAmount);
			
			double priceWithTax = aProduct.GetPriceWithTax(mockTaxCalculator.Object);
			
			Assert.That(47.23, Is.EqualTo(priceWithTax).Within(.005));
		}
	}
}
